package com.member.provider.controller;

import com.member.dto.Contracted;
import com.member.provider.service.ContractedService;
import com.member.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @auther liujian
 * @author liujian
 * 用户签约服务
 * @date 2023/12/15 8:59
 */
@RestController
@RequestMapping("/provider/contracted")
@CrossOrigin
public class MemberContractedController {

    @Autowired
    private ContractedService contractedService;

    @PostMapping("/selectMember")
    public Result selectMemberByContracted(Contracted contracted){
        Integer integer = contractedService.selectMemberByContracted(contracted);
        if (integer>0){
            return Result.success();
        }
        return Result.error("未查询到数据");
    }

    @GetMapping("deleteById")
    public Result deleteById(String channelId){
        int i = contractedService.deleteByPrimaryKey(channelId);
        if (i>0){
            return Result.success("删除成功");
        }
        return Result.error("删除失败");
    }

    @PostMapping("insertContracted")
    public Result insertContracted(Contracted record){
        int insert = contractedService.insert(record);
        if (insert>0){
            return Result.success("添加成功");
        }
        return Result.error("添加失败");
    }


    @PostMapping("/insertSelective")
    public  Result insertSelective(Contracted record){
        int i = contractedService.insertSelective(record);
        if(i>0){
            return Result.success("添加成功");
        }
        return Result.error("添加失败");
    }

    @GetMapping("selectByPrimaryKey")
    public Result selectByPrimaryKey(String channelId){
        Contracted record = contractedService.selectByPrimaryKey(channelId);
            return Result.success(record);
    }

    @PostMapping("updateByPrimaryKeySelective")
    public Result updateByPrimaryKeySelective(Contracted record){
        int i = contractedService.updateByPrimaryKeySelective(record);
        if (i>0){
            return Result.success("修改成功");
        }
        return Result.error("修改失败");
    }

    @PostMapping("updateByPrimaryKey")
    public Result updateByPrimaryKey(Contracted record){
        int i = contractedService.updateByPrimaryKey(record);
        if (i>0){
            return Result.success("修改成功");
        }
        return Result.error("修改失败");
    }



}
